import { HTTP_REQUEST_URL } from '@/config.js';
var baseUrl = HTTP_REQUEST_URL

export const http = function(url, data,Fn,type,Fn2) {
	return uni.request({
		url: baseUrl + url, //仅为示例，并非真实接口地址。
		data: data,
		method: type?type:'POST',
		header: {
			'Authorization': 'Bearer '+uni.getStorageSync('token'),
			'tenantId': uni.getStorageSync('tenantId')
		},
		fail:(err)=>{
			console.log('请求失败',err)
			uni.hideLoading()
		},
		success:(res)=>{
				if(res.data.error){
					uni.showToast({
						icon:'none',
						title:res.data.error.message
					})
					if(Fn2){
						Fn2(res)
					}
				}else{
					Fn(res)
				}
		}
	})
}